-
Notifications
You must be signed in to change notification settings - Fork 3
Switch from Bluepy to Bleak #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
write rx with UUID add badge_bleak add badge_bleak add badge_bleak add badge_bleak add badge_bleak add badge_bleak rewrite utilities using bleak add request handler decorators add request handler decorators add request handler decorators add request handler decorators add request handler decorators rewrite utilities using bleak add request handler decorators
# Conflicts: # BadgeFramework/badge.py # BadgeFramework/bleak_test.py
| @@ -0,0 +1,363 @@ | |||
| import tkinter as tk | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Era-Dorta remove this file and make badge_gui use from badge import OpenBadge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review this file and remove the original gui file
| print(" mic gain: FAIL ") | ||
| else: | ||
| print(" mic mode: FAIL ") | ||
| print(" mic mode: FAIL ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be updated to bleak
Era-Dorta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing the GUI file
BadgeFramework/badge_gui_bleak.py
Outdated
| import pandas as pd | ||
| from badge import OpenBadge | ||
| from datetime import datetime | ||
| # import numpy as np |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import
| # import numpy as np |
BadgeFramework/badge_gui_bleak.py
Outdated
| import sys | ||
| import time | ||
| import ntplib | ||
| # from functools import partial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import
| # from functools import partial |
BadgeFramework/badge_gui_bleak.py
Outdated
| # import numpy as np | ||
| import sys | ||
| import time | ||
| import ntplib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove ntplib
| import ntplib |
BadgeFramework/badge_gui_bleak.py
Outdated
| # def get_ntp_time(ntp_server='pool.ntp.org'): | ||
| # # Create an NTP client | ||
| # client = ntplib.NTPClient() | ||
| # | ||
| # try: | ||
| # # Query the NTP server | ||
| # response = client.request(ntp_server) | ||
| # | ||
| # # Convert the response to datetime | ||
| # ntp_time = datetime.fromtimestamp(response.tx_time, tz=timezone.utc) | ||
| # print("NTP time:", ntp_time.strftime('%Y-%m-%d %H:%M:%S %Z')) | ||
| # return ntp_time | ||
| # | ||
| # except Exception as e: | ||
| # print("Could not connect to NTP server:", e) | ||
| # return None | ||
|
|
||
|
|
||
| # Use a local NTP server (replace with your server IP if needed) | ||
| # ntp_server_ip = '192.168.1.100' # Example IP for a local NTP server | ||
| # ntp_time = get_ntp_time(ntp_server=ntp_server_ip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented out code
| # def get_ntp_time(ntp_server='pool.ntp.org'): | |
| # # Create an NTP client | |
| # client = ntplib.NTPClient() | |
| # | |
| # try: | |
| # # Query the NTP server | |
| # response = client.request(ntp_server) | |
| # | |
| # # Convert the response to datetime | |
| # ntp_time = datetime.fromtimestamp(response.tx_time, tz=timezone.utc) | |
| # print("NTP time:", ntp_time.strftime('%Y-%m-%d %H:%M:%S %Z')) | |
| # return ntp_time | |
| # | |
| # except Exception as e: | |
| # print("Could not connect to NTP server:", e) | |
| # return None | |
| # Use a local NTP server (replace with your server IP if needed) | |
| # ntp_server_ip = '192.168.1.100' # Example IP for a local NTP server | |
| # ntp_time = get_ntp_time(ntp_server=ntp_server_ip) |
BadgeFramework/badge_gui_bleak.py
Outdated
| return_message = await sensor_operation(t=datetime.now().timestamp()) | ||
| else: | ||
| return_message = await sensor_operation() | ||
| # print(return_message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # print(return_message) |
BadgeFramework/badge_gui_bleak.py
Outdated
|
|
||
| self.title("Badge Status Monitor") | ||
| self.badges = pd.read_csv('mappings2.csv') | ||
| # self.badges = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all commented out code
BadgeFramework/badge_gui_bleak.py
Outdated
| self.scrollbar.grid(row=0, column=0, sticky="ns") | ||
| self.canvas.grid(row=0, column=1, sticky="nsew") | ||
|
|
||
| # Bind mouse scroll to canvas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all comments that do not add anything to the code, as this one, which says the say as the function name
BadgeFramework/badge_gui_bleak.py
Outdated
| self.timestamp_labels[badge] = (timestamp_label, elapsed_time_label) | ||
| self.sensor_lights[badge] = sensor_light_canvases | ||
|
|
||
| def bind_mouse_scroll(self, widget): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add type hints to all the functions?
BadgeFramework/badge_gui_bleak.py
Outdated
|
|
||
| def get_badge_address(self, badge_id: int) -> str: | ||
| badge = self.badges[self.badges['Participant Id'] == badge_id] | ||
| address = badge['Mac Address'].to_numpy()[0] # There should be a more elegant way to do this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about?
| address = badge['Mac Address'].to_numpy()[0] # There should be a more elegant way to do this | |
| address = badge['Mac Address'].values[0] |
Era-Dorta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional review
| SENSOR_ALL = 0 | ||
| SENSOR_MICROPHONE = 1 | ||
| SENSOR_IMU = 2 | ||
| SENSOR_SCAN = 3 | ||
| SENSOR_CHECK_STATUS = 100 | ||
| SENSOR_TIMEOUT = 15 | ||
|
|
||
| SENSOR_START = True | ||
| SENSOR_STOP = False | ||
| CHECK_SYNC = True | ||
| CHECK_NO_SYNC = False | ||
|
|
||
| BADGES_ALL = -1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explain all of these constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just like the response_tags in badge_protocol to increase readability when passing the parameters.
| sync_button.grid(row=0, column=10, padx=5, pady=5) | ||
|
|
||
| # Create rows for each badge | ||
| badges_list = list(range(1, len(self.badges) + 5)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes no sense, why make the list longer by 5?
BadgeFramework/badge_protocol.py
Outdated
| Response_free_sdc_space_response_tag = 5 | ||
| Response_sdc_errase_all_response_tag = 32 | ||
| Response_get_imu_data_response_tag = 34 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what happened with this file but I think all the changes should be removed
| nrf_delay_ms(100); | ||
| nrf_delay_ms(1000); | ||
| nrf_gpio_pin_write(LED, LED_OFF); //turn off LED | ||
| nrf_delay_ms(100); | ||
| nrf_delay_ms(1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to also revert this changes
…ge.py and badge_protocol.py, test.py
No description provided.